<?php
namespace view;

class HTMLAdminView {
    private $applicationModel;


    /**
    * __constructor
    */
    public function __construct()     {
        $this->applicationModel = new \model\ApplicationModel();
    }


    /**
    * @return string HTML
    *
    * return -> visar admin-meny
    */
    public function returnAdminMenu() {
        return "<h3><a href='?editUsers'>Edit Users</a></h3>";
    }


    /**
    * @param array $users
    * @return string HTML
    *
    * return -> hämtar och visar alla användare i admin-menyn
    */
    public function returnUserListInHTML($users) {
        $HTMLusers = "<h2>List all Users</h2>";

        while($row = mysql_fetch_array($users)) {

            if ($row[3] == 1) {
                $isAdmin="Yes";
            } else {
               $isAdmin="No";
            }
            $HTMLusers .="  <div class='users'>
                                    <p>Username: $row[1] - is Admin: $isAdmin
                                    <a href='?".$this->applicationModel->m_setAdminURL."=$row[0]'>Set as admin</a> -
                                    <a href='?".$this->applicationModel->m_removeUserURL."=$row[0]'>Remove user and posts/comments</a>
                                    </p>
                                    <br>
                            </div>";
        }

        return $HTMLusers;
    }


    /**
    * @return string HTML
    *
    * return -> visar meddelande om att användaren är borttagen
    */
    public function returnRemovedUser() {
        return "<h2>User Successfully removed</h2>";
    }


    /**
    * @return string HTML
    *
    * return -> visar meddelande om att Admin-användaren är satt
    */
    public function returnAdminUserSet() {
        return "<h2>Admin User Successfully set</h2>";
    }


}

